package cn.java78.jdbc;

import cn.myschool.util.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author oldliu
 * @since 1.0
 */
public class StudentSearch {
    public static void main(String[] args) {
        Connection connection = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            connection = DBUtil.getConnection();
            st = connection.createStatement();
            rs = st.executeQuery("select stuno as xuehao,sname,qq,enterdate from s_student order by stuno desc limit 0,20");
            while (rs.next()){
                System.out.println(rs.getLong("xuehao"));
                System.out.println(rs.getString(2));
                System.out.println(rs.getString(3));
                System.out.println(rs.getDate(4));
                System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(rs,st,connection);
        }

    }
}
